<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
    <meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="white">
    <link rel="stylesheet" href="../dist/main.css">
</head>
<body>
<div id="chi">
    <div id="refreshContainer" class="mui-content mui-scroll-wrapper" style="display: none">
        <div class="mui-scroll">
            <div class="mainBox" style="position: relative;">
                <button class="finder">全部</button>
                <i class="mui-icon mui-icon-arrowdown downIcon"></i>
                <div id="menu-wrapper" class="menu-wrapper" style="position: absolute;z-index: 1;display: none ">
                    <div id="menu" class="menu">
                        <ul class="mui-table-view mui-table-view-inverted">
                            <li class="mui-table-view-cell mui-active">
                                <a href="javascript:;">全部</a>
                            </li>
                            <li class="mui-table-view-cell" class="mowNo">
                                <a href="javascript:;">盈利订单</a>
                            </li>
                            <li class="mui-table-view-cell" class="mowNo">
                                <a href="javascript:;">亏损订单</a>
                            </li>

                        </ul>
                    </div>
                </div>
            </div>
            <ul class="mui-table-view" id="mui-table-view" style="padding-bottom: 1rem">

            </ul>
            <div id="noDatas2" style="display: none" class="noDatas">
                <img src="../img/warnNoOrders(310_240).png" alt="">
                <p>暂无历史订单</p>
                <div class="btns" style="display: none">
                    <button class="mui-btn mui-btn-warning mui-btn-outlined" id="bidingBtn">绑定MT5账号</button>
                </div>
            </div>

        </div>
    </div>

    <div id="noDatas" style="display: none" class="noDatas">
        <img src="../img/warnNoOrders(310_240).png" alt="">
        <p>暂无历史订单</p>
        <div class="btns" style="display: none">
            <button class="mui-btn mui-btn-warning mui-btn-outlined" id="bidingBtn">绑定MT5账号</button>
        </div>
    </div>
</div>
<view></view>
<script src="../dist/main.js"></script>

<script>
    $("title").html(mt5Obj.title)
    var postDatas={
        limit:10,
        offset:0,
    };

    /*查看自己持仓*/
    function chiList(down) {
        var str = "";
        var icon="";
        var oImg="";
        var profit="";
        var finalProfit="";
        $.ajax({
            url: mt5Obj.allUrl + "mt/user/coverOrder",
            data:postDatas,
            success: function (data) {
                if(data.error){
                    if(data.error.code==1003111133){
                        $("#noDatas").show();
                        $("#noDatas .btns").show();
                    }
                }else {
                    if(data.total==0){
                        $("#noDatas2").show();
                    }else{
                        $("#noDatas2").hide();
                    }
                }

                if (data.rows) {
                    $("#refreshContainer").show();

                    mui('#refreshContainer').pullRefresh().endPulldownToRefresh();
                    noMore(down,data);
                    for(x in data.rows){

                        if (data.rows[x].sourceIcon){
                            icon=data.rows[x].sourceIcon
                        }else {
                            icon="../img/signalHead(120_120).png"
                        }

                        if (data.rows[x].action==0){
                            oImg="../img/labelSell(40_40).png"
                        }else {
                            oImg="../img/labelBuy(40_40).png"
                        }

                        if(data.rows[x].profit>=0){
                            profit="+$"+data.rows[x].profit.toLocaleString()
                            finalProfit= '<span class="right green">'+profit+'</span>'
                        }else{
                            profit="-$"+data.rows[x].profit.toString().split("-")[1].toLocaleString()
                            finalProfit= '<span class="right red">'+profit+'</span>'
                        }



                        str = ' <li class="mui-table-view-cell mui-collapse">' +
                            '                    <a class="mui-navigate-right" href="#">'+data.rows[x].order+'</a>' +
                            '                    <div class="showContent">' +
                            '                        <div class="mainBox">' +
                            '                            <div class="mui-content">' +
                            '                                <div class="mui-row clearFix">' +
                            '                                <div class="mui-col-sm-6 mui-col-xs-6">' +
                            '                                    <div  class="chiTx" style="background:url('+icon +' );background-size: cover"></div>' +
                            '                                    <span>'+data.rows[x].sourceName+'</span>' +
                            '                                </div>' +
                            '                                <div class="mui-col-sm-6 mui-col-xs-6">' +
                            '                                    平仓盈亏：' +
                            finalProfit +
                            '                                </div>' +
                            '                            </div>' +
                            '                                <div class="mui-row clearFix">' +
                            '                                    <div class="mui-col-sm-6 mui-col-xs-6">' +
                            data.rows[x].symbol +
                            '                                    <img src="'+oImg+'" alt="" class="duo">' +
                            '                                    </div>' +
                            '                <div class="mui-col-sm-6 mui-col-xs-6">' +
                            '                    交易量:' +
                            '                    <span class="right yellow">'+data.rows[x].shoushu+'手</span>' +
                            '                </div>' +

                            '                                </div>' +
                            '                   </div>' +
                            '             </div>' +
                            '<div class="mui-collapse-content">' +
                            '        <div class="mui-content">' +
                            '            <div class="mui-row clearFix">' +
                            '                <div class="mui-col-sm-6 mui-col-xs-6">' +
                            '                    开仓价格：' +
                            '                    <span class="gray">'+data.rows[x].openPrice +'</span>' +
                            '                </div>' +
                            '                                    <div class="mui-col-sm-6 mui-col-xs-6">' +
                            '                                        止盈：' +
                            '                                        <span class="right gray">'+data.rows[x].tp+'</span>' +
                            '                                    </div>' +

                            '            </div>' +
                            '            <div class="mui-row clearFix">' +
                            '                <div class="mui-col-sm-6 mui-col-xs-6">' +
                            '                    <span>开仓时间：</span>' +
                            '                    <span class="gray">'+data.rows[x].openTime+'</span>' +
                            '                </div>' +
                            '                <div class="mui-col-sm-6 mui-col-xs-6">' +
                            '                    止损：' +
                            '                    <span class="right gray">'+data.rows[x].sl+'</span>' +
                            '                </div>' +
                            '            </div>' +
                            '        </div>' +
                            '            <div class="mui-row clearFix">' +
                            '                <div class="mui-col-sm-12 mui-col-xs-12">' +
                            '                    <span>平仓价格：</span>' +
                            '                    <span class="gray">'+data.rows[x].closePrice+'</span>' +
                            '                </div>' +
                            '                <div class="mui-col-sm-12 mui-col-xs-12">' +
                            '                    平仓时间：' +
                            '                    <span class="gray">'+data.rows[x].closeTime
                            +'</span>' +
                            '                </div>' +
                            '            </div>' +
                            '        </div>' +
                            '</div>' +
                            '</li>';

                        $("#mui-table-view").append(str)
                    }


                }



            }
        })
    }

    //    上拉刷新配置
    refreshApp();
    //下拉刷新
    function  refrecha() {
        $("#mui-table-view li").remove();
        postDatas.offset=0;
        self=this;
        chiList("down")

    }
    //    上拉加载
    function loadMore() {
        var offset=postDatas.offset
        self=this
        postDatas.offset=postDatas.offset+=10;
        chiList()
    }

//    筛选
    mui("#menu").on('tap','a',function(){
        postDatas={
            limit:10,
            offset:0,
        };
        var inner=$(this).html();
        $(".finder").html(inner);
        $("#menu-wrapper").hide();
        $(this).parent().addClass("mui-active");
        $(this).parent().siblings().removeClass("mui-active");
        if(inner=="全部"){

        }else if(inner=="盈利订单"){
            postDatas.profit=0;


        }
        else if(inner=="亏损订单"){
            postDatas.profit=1;

        }

        $("#mui-table-view li").remove();
        chiList()

    })
    mui("body").on('tap','.finder',function(){
        $("#menu-wrapper").show();

    })
    mui("body").on('tap','#mui-table-view',function(){
        $("#menu-wrapper").hide();

    })
//    去绑定
    mui("body").on('tap','#bidingBtn',function(){
        bolBinding()
        if(sessionStorage.getItem("bolBindingMT5")=="1"){
            mui.alert("您有账号正在审核中，审核通过后可绑定新的MT5账号");
        }else{
            goBinding();

        }

    })


</script>

</body>
</html>



